package com.sunday.aomicaichang.ui.order;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.sunday.common.adapter.CommenAdapter;
import com.sunday.common.adapter.ViewHolder;
import com.sunday.common.base.BaseActivity;
import com.sunday.common.model.ResultDO;
import com.sunday.common.utils.MD5Utils;
import com.sunday.common.utils.SharePerferenceUtils;
import com.sunday.common.utils.SpannalbeStringUtils;
import com.sunday.common.utils.StringUtils;
import com.sunday.common.utils.ToastUtils;
import com.sunday.common.widgets.ClearEditText;
import com.sunday.common.widgets.NoScrollListview;
import com.sunday.common.widgets.taosty.Toasty;
import com.sunday.aomicaichang.R;
import com.sunday.aomicaichang.base.BaseApp;
import com.sunday.aomicaichang.constValues.ConstValue;
import com.sunday.aomicaichang.http.ApiClient;
import com.sunday.aomicaichang.model.Coupon;
import com.sunday.aomicaichang.ui.coupon.CouponActivity;
import com.sunday.aomicaichang.ui.login.ForgetPasswordActivity;
import com.sunday.aomicaichang.ui.my.AddressListActivity;
import com.sunday.aomicaichang.ui.my.PaySetting1Activity;
import com.sunday.aomicaichang.widgets.PayEdit;
import com.sunday.member.entity.Member;
import com.sunday.member.entity.addr.Address;
import com.sunday.member.entity.order.OrderConfirm;
import com.sunday.member.entity.order.OrderItem;
import com.sunday.member.entity.order.OrderProduct;
import com.sunday.member.http.MemberClient;
import com.sunday.member.utils.SignUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


public class OrderConfirmActivity extends BaseActivity {


    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.user_name)
    TextView userName;
    @Bind(R.id.user_mobile)
    TextView userMobile;
    @Bind(R.id.linearlayout)
    LinearLayout linearlayout;
    @Bind(R.id.user_addr)
    TextView userAddr;
    @Bind(R.id.select_img)
    ImageView selectImg;
    @Bind(R.id.address_layout)
    RelativeLayout addressLayout;
    @Bind(R.id.list_view)
    NoScrollListview listView;
    @Bind(R.id.total_money)
    TextView totalMoney;
    @Bind(R.id.edit_remark)
    ClearEditText editRemark;
    @Bind(R.id.total_money_bottom)
    TextView totalMoneyBottom;
    @Bind(R.id.confirm_pay)
    TextView confirmPay;
    @Bind(R.id.bottom_layout)
    RelativeLayout bottomLayout;
    @Bind(R.id.top)
    LinearLayout top;
    @Bind(R.id.tv_coupon)
    TextView tvCoupon;
    @Bind(R.id.ly_coupon)
    RelativeLayout lyCoupon;
    @Bind(R.id.tv_remaining_price)
    TextView tvRemainingPrice;
    @Bind(R.id.img_check)
    ImageView imgCheck;
    @Bind(R.id.tv_type_owner)
    TextView tvTypeOwner;
    @Bind(R.id.tv)
    TextView tv;
    @Bind(R.id.tv_type_service)
    TextView tvTypeService;
    @Bind(R.id.send_address)
    TextView sendAddress;
    @Bind(R.id.ly_owner)
    RelativeLayout lyOwner;
    @Bind(R.id.left_txt)
    TextView leftTxt;
    @Bind(R.id.right_menu)
    ImageView rightMenu;
    @Bind(R.id.left_menu)
    ImageView leftMenu;
    @Bind(R.id.total_layout)
    RelativeLayout totalLayout;
    @Bind(R.id.img1)
    ImageView img1;
    @Bind(R.id.ly1)
    RelativeLayout ly1;
    @Bind(R.id.tv1)
    TextView tv1;
    @Bind(R.id.send_price)
    TextView sendPrice;
    @Bind(R.id.tv_service)
    TextView tvService;
    @Bind(R.id.send_mag)
    TextView sendMag;
    @Bind(R.id.tv_send_mag)
    TextView tvSendMag;
    @Bind(R.id.ly_service)
    RelativeLayout lyService;

    private OrderConfirm orderConfirm;
    private CommenAdapter<OrderProduct> adapter;
    private int isUsedBalance = 0;
    private boolean selectBalance = false;
    private Coupon coupon = new Coupon();
    private int couponId;
    private int sendType = 1;
    private String password;
    private String cartId;
    private long productId;
    private int villageId;
    private int buyNum;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_confirm);
        ButterKnife.bind(this);
        title.setText("确认订单");
        leftMenu.setVisibility(View.VISIBLE);
        leftMenu.setImageResource(R.mipmap.return_white);
        orderConfirm = (OrderConfirm) getIntent().getSerializableExtra("orderConfirm");
        cartId = getIntent().getStringExtra("cartIds");
        productId=getIntent().getLongExtra("productId",-1);
        buyNum=getIntent().getIntExtra("buyNum",-1);
        villageId= SharePerferenceUtils.getIns(mContext).getInt(ConstValue.AREA,0);
        initView();
        getDefaultAddr();
    }

    private void initView() {
        if (orderConfirm == null) {
            return;
        }
        if (orderConfirm.getShopName() != null)
            tv.setText(orderConfirm.getShopName());
        if (TextUtils.isEmpty(orderConfirm.getSendAddress())) {
            userName.setText("暂无收货地址");
            userAddr.setText("请选择收货地址");
        } else {
            userAddr.setText(orderConfirm.getSendAddress());
        }
        if (orderConfirm.getBalance() == null) {
            tvRemainingPrice.setText("0元");
        } else {
            tvRemainingPrice.setText(orderConfirm.getBalance() + "元");
        }
        if (orderConfirm.getSendAddress() != null)
            sendAddress.setText(orderConfirm.getSendAddress());
        if(orderConfirm.getSendAmount()!=null)
        tvService.setText(String.format("￥%s", orderConfirm.getSendAmount().setScale(2, RoundingMode.HALF_UP)));
        if(orderConfirm.getSendMsg()!=null)
        tvSendMag.setText(orderConfirm.getSendMsg());
//            totalMoney.setText(String.format("￥%s", orderConfirm.getPayAmount().setScale(2, RoundingMode.HALF_UP)));
//            totalMoneyBottom.setText(SpannalbeStringUtils.setTextColor("总金额：", mContext.getResources().getColor(R.color.price_yellow)));
//            totalMoneyBottom.append(SpannalbeStringUtils.setTextColor(String.format("￥%s", orderConfirm.getPayAmount().setScale(2, RoundingMode.HALF_UP)),
//                    mContext.getResources().getColor(R.color.price_yellow)));

        if(sendType==1){
            tvTypeOwner.setSelected(false);
            tvTypeService.setSelected(true);
            lyOwner.setVisibility(View.GONE);
            lyService.setVisibility(View.VISIBLE);
                totalMoney.setText(String.format("￥%s", orderConfirm.getTotalAmount().setScale(2, RoundingMode.HALF_UP)));
                totalMoneyBottom.setText(SpannalbeStringUtils.setTextColor("总金额：", mContext.getResources().getColor(R.color.price_yellow)));
                totalMoneyBottom.append(SpannalbeStringUtils.setTextColor(String.format("￥%s", orderConfirm.getPayAmount().setScale(2, RoundingMode.HALF_UP)),
                        mContext.getResources().getColor(R.color.price_yellow)));

        }else {
            tvTypeOwner.setSelected(true);
            tvTypeService.setSelected(false);
            lyOwner.setVisibility(View.VISIBLE);
            lyService.setVisibility(View.GONE);
            if (orderConfirm.getSendAmount() != null) {
                    totalMoney.setText(String.format("￥%s", (orderConfirm.getTotalAmount().subtract(orderConfirm.getSendAmount())).setScale(2, RoundingMode.HALF_UP)));
                    totalMoneyBottom.setText(SpannalbeStringUtils.setTextColor("总金额：", mContext.getResources().getColor(R.color.price_yellow)));
                    totalMoneyBottom.append(SpannalbeStringUtils.setTextColor(String.format("￥%s", (orderConfirm.getPayAmount().subtract(orderConfirm.getSendAmount())).setScale(2, RoundingMode.HALF_UP)),
                            mContext.getResources().getColor(R.color.price_yellow)));

            } else {
                    totalMoney.setText(String.format("￥%s", (orderConfirm.getTotalAmount()).setScale(2, RoundingMode.HALF_UP)));
                    totalMoneyBottom.setText(SpannalbeStringUtils.setTextColor("总金额：", mContext.getResources().getColor(R.color.price_yellow)));
                    totalMoneyBottom.append(SpannalbeStringUtils.setTextColor(String.format("￥%s", (orderConfirm.getPayAmount()).setScale(2, RoundingMode.HALF_UP)),
                            mContext.getResources().getColor(R.color.price_yellow)));

            }
        }
                if(coupon.getDecuAmount()!=null)
        tvCoupon.setText("-" + coupon.getDecuAmount());
        if (orderConfirm.getProducts() != null && !orderConfirm.getProducts().isEmpty()) {
            adapter = new CommenAdapter<OrderProduct>(mContext, orderConfirm.getProducts(), R.layout.list_order_confirm_product) {
                @Override
                public void convert(ViewHolder helper, OrderProduct item, int position) {
                    bind(helper, item);
                }
            };
            listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();
        }

    }
    private void countCart(int isUsedBalance,int couponId,int sendType) {

        String nonce = MD5Utils.random();
        String[] str1 = new String[]{"cartIds","villageId", "isUsedBalance", "couponId", "sendType","nonce"};
        String[] str2 = new String[]{cartId, String.valueOf(villageId), String.valueOf(isUsedBalance), String.valueOf(couponId),String.valueOf(sendType), nonce};
        showLoadingDialog(0);
        Call<ResultDO<OrderConfirm>> call = ApiClient.getApiAdapter().countCart(cartId,
                villageId, isUsedBalance, couponId, sendType,nonce, SignUtil.getSign(str1, str2));
        call.enqueue(new Callback<ResultDO<OrderConfirm>>() {
            @Override
            public void onResponse(Call<ResultDO<OrderConfirm>> call, Response<ResultDO<OrderConfirm>> response) {
                dissMissDialog();
                if (isFinish || response.body() == null) {
                    return;
                }
                if (response.body().getCode() == 0) {
                   orderConfirm= response.body().getResult();
                    initView();
                    getDefaultAddr();
                }
            }

            @Override
            public void onFailure(Call<ResultDO<OrderConfirm>> call, Throwable t) {
                dissMissDialog();
            }
        });

    }
    private void buyNow(int isUsedBalance,int couponId,int sendType,int buyNum){
        String nonce= MD5Utils.random();
        String[] str1=new String[]{"productId","villageId","number","isUsedBalance","couponId","sendType","nonce"};
        String[] str2=new String[]{String.valueOf(productId),String.valueOf(villageId),String.valueOf(buyNum),String.valueOf(isUsedBalance),String.valueOf(couponId),String.valueOf(sendType),nonce};
        showLoadingDialog(0);
        Call<ResultDO<OrderConfirm>>call= ApiClient.getApiAdapter().countBuyNow(productId,buyNum,villageId,isUsedBalance,couponId,sendType,nonce, SignUtil.getSign(str1,str2));
        call.enqueue(new Callback<ResultDO<OrderConfirm>>() {
            @Override
            public void onResponse(Call<ResultDO<OrderConfirm>> call, Response<ResultDO<OrderConfirm>> response) {
                dissMissDialog();
                if(response.body()==null){return;}
                if (response.body().getCode()==0){
                    orderConfirm= response.body().getResult();
                    initView();
                    getDefaultAddr();
                }
            }

            @Override
            public void onFailure(Call<ResultDO<OrderConfirm>> call, Throwable t) {
                dissMissDialog();
                Toasty.error(mContext,"网络连接错误").show();
            }
        });
    }
    private void bind(ViewHolder helper, OrderProduct item) {
        ImageView imageView = helper.getView(R.id.product_img);
        if (!TextUtils.isEmpty(item.getImage())) {
            Picasso.with(mContext)
                    .load(item.getImage())
                    .error(R.mipmap.ic_product)
                    .resize(150, 150)
                    .into(imageView);
        }
        ((TextView) helper.getView(R.id.product_title)).setText(item.getName());
        ((TextView) helper.getView(R.id.product_price)).setText(String.format("￥%s", item.getPrice().setScale(2, RoundingMode.HALF_UP)));
        ((TextView) helper.getView(R.id.product_num)).setText(String.format("X%d", item.getNum()));
        ((TextView) helper.getView(R.id.product_spec)).setText("规格:" + item.getStandard());
    }

    private Address address;

    private void getDefaultAddr() {
        String nonce = MD5Utils.random();
        long memberId = BaseApp.getInstance().getMember().getId();
        String[] str1 = new String[]{"nonce"};
        String[] str2 = new String[]{nonce};
        showLoadingDialog(0);
        Call<ResultDO<List<Address>>> call = MemberClient.getApiAdapter().getAddrList(nonce, SignUtil.getSign(str1, str2));
        call.enqueue(new Callback<ResultDO<List<Address>>>() {
            @Override
            public void onResponse(Call<ResultDO<List<Address>>> call, Response<ResultDO<List<Address>>> response) {
                if (isFinish) {
                    return;
                }
                dissMissDialog();
                ResultDO<List<Address>> resultDO = response.body();
                if (resultDO == null) {
                    return;
                }
                if (resultDO.getCode() == 0) {
                    if (resultDO.getResult() == null) {
                        return;
                    }
                    if (resultDO.getResult() != null && !resultDO.getResult().isEmpty()) {
                        address = resultDO.getResult().get(0);
                        setAddr(address);
                    }
                }
            }

            @Override
            public void onFailure(Call<ResultDO<List<Address>>> call, Throwable t) {
                dissMissDialog();
                ToastUtils.showToast(mContext, R.string.network_error);
            }
        });
    }

    private final static int REQUEST_ADDR = 0x1111;
    private final static int REQUEST_COUPON = 0x1112;

    @OnClick({R.id.confirm_pay, R.id.address_layout, R.id.tv_type_owner, R.id.tv_type_service, R.id.ly_coupon, R.id.img_check, R.id.left_menu})
    void onClick(View v) {
        switch (v.getId()) {
            case R.id.confirm_pay:
                if (address == null) {
                    Toasty.error(mContext, "请选择收货地址").show();
                    return;
                }
                if (selectBalance) {
                    showPayDialog();
                } else {
                    creatOrder();
                }
                break;
            case R.id.address_layout:
                intent = new Intent(mContext, AddressListActivity.class);
                intent.putExtra("isSelectMode", true);
                startActivityForResult(intent, REQUEST_ADDR);
                break;
            case R.id.tv_type_owner:
                sendType = 2;
                if(productId==-1||buyNum==-1){
                    countCart(isUsedBalance,couponId,sendType);
                }else {
                    buyNow(isUsedBalance,couponId,sendType,buyNum);
                }
                break;
            case R.id.tv_type_service:
                sendType = 1;

                if(productId==-1||buyNum==-1){
                    countCart(isUsedBalance,couponId,sendType);
                }else {
                    buyNow(isUsedBalance,couponId,sendType,buyNum);
                }
                break;
            case R.id.ly_coupon:
                intent = new Intent(mContext, CouponActivity.class);
                intent.putExtra("amount", String.valueOf(orderConfirm.getTotalAmount()));
                startActivityForResult(intent, REQUEST_COUPON);
                break;
            case R.id.left_menu:
                onBackPressed();
                break;
            case R.id.img_check:
                Member member = (Member) SharePerferenceUtils.getIns(mContext).getOAuth();
                if(member.getIsPayPassword()==0){
                    isPayPassword();
                    return;
                }
                BigDecimal bigDecimal = BigDecimal.valueOf(0.00);
//                BigDecimal payMoney;
//                if(sendType==1){
//                    payMoney=orderConfirm.getPayAmount();
//                }else {
//                    if(orderConfirm.getSendAmount()!=null) {
//                        payMoney = orderConfirm.getPayAmount().subtract(orderConfirm.getSendAmount());
//                    }else {
//                        payMoney=orderConfirm.getPayAmount();
//                    }
//                }
                if (orderConfirm.getBalance() == null || orderConfirm.getBalance().compareTo(bigDecimal) <= 0) {
                    ToastUtils.showToast(mContext, "余额不足，请充值！");
                    return;
                }
//                if (coupon.getDecuAmount() != null)
//                    if (orderConfirm.getBalance().compareTo(payMoney.subtract(coupon.getDecuAmount())) < 0) {
//                        ToastUtils.showToast(mContext, "余额不足，请充值！");
//                        return;
//                    } else {
//                        if (orderConfirm.getBalance().compareTo(payMoney) < 0) {
//                            ToastUtils.showToast(mContext, "余额不足，请充值！");
//                            return;
//                        }
//                    }
                imgCheck.setSelected(!selectBalance);
                selectBalance = !selectBalance;
                if (selectBalance) {
                    isUsedBalance = 1;
                    if(productId==-1||buyNum==-1){
                        countCart(isUsedBalance,couponId,sendType);
                    }else {
                        buyNow(isUsedBalance,couponId,sendType,buyNum);
                    }
                } else {
                    isUsedBalance = 0;
                    if(productId==-1||buyNum==-1){
                        countCart(isUsedBalance,couponId,sendType);
                    }else {
                        buyNow(isUsedBalance,couponId,sendType,buyNum);
                    }
                }
                break;
        }
    }

    private void isPayPassword(){
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle("提示");
        builder.setMessage("未设置支付密码，是否跳到设置支付界面？");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(mContext, PaySetting1Activity.class);
                startActivity(intent);
                dialog.dismiss();
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) {
            return;
        }
        switch (requestCode) {
            case REQUEST_ADDR:
                address = (Address) data.getSerializableExtra("address");
                setAddr(address);
                break;
            case REQUEST_COUPON:
                coupon = (Coupon) data.getSerializableExtra("coupon");
                if (coupon == null)
                    return;
                couponId = coupon.getId();

                if(productId==-1||buyNum==-1){
                    countCart(isUsedBalance,couponId,sendType);
                }else {
                    buyNow(isUsedBalance,couponId,sendType,buyNum);
                }
                imgCheck.setSelected(false);
                selectBalance = false;
                isUsedBalance = 0;
                break;
        }
    }

    private void setAddr(Address address) {
        if (address == null) {
            userName.setText("暂无收货地址");
            userMobile.setText("");
            userAddr.setText("请添加收货地址");
        } else {
            userName.setText("姓名:" + address.getReceiveName());
            userMobile.setText(address.getReceiveMobile());
            userAddr.setText(String.format("%1$s",address.getReceiveAddress()));
        }
    }


    private List<String> cartIds = new ArrayList<>();

    private void creatOrder() {
        cartIds.clear();
        if (orderConfirm.getProducts() != null && !orderConfirm.getProducts().isEmpty()) {
            for (OrderProduct item : orderConfirm.getProducts()) {
                cartIds.add(String.valueOf(item.getCartId()));
            }
        }
        int villageId = SharePerferenceUtils.getIns(mContext).getInt(ConstValue.AREA, 0);
        String nonce = MD5Utils.random();
        String addressId = String.valueOf(address.getId());
        String remark = editRemark.getText().toString();
        String cartIdStr = StringUtils.listToString(cartIds);
        String[] str1 = new String[]{"villageId", "payPassword", "couponId", "sendType", "isUsedBalance", "cartIds", "addressId", "remark", "nonce"};
        String[] str2 = new String[]{String.valueOf(villageId), password, String.valueOf(couponId), String.valueOf(sendType), String.valueOf(isUsedBalance), cartIdStr, addressId, remark, nonce};
        showLoadingDialog(0);
        Call<ResultDO<OrderItem>> call = MemberClient.getApiAdapter().createOrder(cartIdStr, sendType, couponId, isUsedBalance, address.getId(), villageId,
                password, remark, nonce, SignUtil.getSign(str1, str2));
        call.enqueue(new Callback<ResultDO<OrderItem>>() {
            @Override
            public void onResponse(Call<ResultDO<OrderItem>> call, Response<ResultDO<OrderItem>> response) {
                if (isFinish || response.body() == null) {
                    return;
                }
                dissMissDialog();
                if (response.body().getCode() == 0) {
                    //暂时先不支付 直接跳转采购订单页面
                    //intent=new Intent(mContext,BuyOrderListActivity.class);
                    // startActivity(intent);
                    /*intent = new Intent(mContext, PaySuccessActivity.class);
                    intent.putExtra("totalMoney", String.format("￥%s", orderConfirm.getPayAmount().setScale(2, RoundingMode.HALF_UP)));
                    intent.putExtra("address", address);
                    startActivity(intent);*/
                    OrderItem orderItem=response.body().getResult();
                    if(orderItem.getIsNeedToPay()==0){
                        intent = new Intent(mContext, PaySuccessActivity.class);
                        intent.putExtra("totalMoney",totalMoney.getText().toString() );
                        intent.putExtra("address", orderItem.getReceiveAddress());
                        intent.putExtra("name", orderItem.getReceiveName());
                        intent.putExtra("mobile", orderItem.getReceiveMobile());
                        startActivity(intent);
                        finish();
                    }else {
                        intent = new Intent(mContext, PayConfirmActivity.class);
                        intent.putExtra("order", response.body().getResult());
                        intent.putExtra("type", 0);
                        startActivity(intent);
                        finish();
                    }
                } else {
                    Toasty.error(mContext, response.body().getMessage()).show();
                }
            }

            @Override
            public void onFailure(Call<ResultDO<OrderItem>> call, Throwable t) {
                dissMissDialog();
                Toasty.error(mContext, "网络连接错误").show();
            }
        });
    }

    private void showPayDialog() {
        final AlertDialog myDialog = new AlertDialog.Builder(mContext).create();
        myDialog.setView(((Activity) mContext).getLayoutInflater().inflate(R.layout.pop_pay, null));
        myDialog.show();
        myDialog.getWindow().setContentView(R.layout.pop_pay);
        myDialog.getWindow().setGravity(Gravity.BOTTOM);
        TextView money = (TextView) myDialog.getWindow().findViewById(R.id.money);
        TextView btn = (TextView) myDialog.getWindow().findViewById(R.id.btn_forget_password);
        ImageView dismiss = (ImageView) myDialog.getWindow().findViewById(R.id.dismiss);
        final PayEdit edtPassword = (PayEdit) myDialog.getWindow().findViewById(R.id.edt_password);
        final InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(edtPassword, InputMethodManager.SHOW_IMPLICIT);
        money.setText(String.valueOf(orderConfirm.getBalance()));
        edtPassword.setOnTextEndListener(new PayEdit.OnTextEndListener() {
            @Override
            public void onTextEnd(String str) {
                password = str;
                imm.hideSoftInputFromWindow(edtPassword.getWindowToken(), 0);
                creatOrder();
                myDialog.dismiss();
            }
        });
        dismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imm.hideSoftInputFromWindow(edtPassword.getWindowToken(), 0);
                myDialog.dismiss();
            }
        });
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intent = new Intent(mContext, ForgetPasswordActivity.class);
                intent.putExtra("phone", BaseApp.getInstance().getMember().getMobile());
                startActivity(intent);
            }
        });
    }
}
